package edu.whut.service.impl;

import edu.whut.dao.FollowerDao;
import edu.whut.entity.Follower;
import edu.whut.service.FollowerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

@Service
public class FollowerServiceImpl implements FollowerService {

    @Resource
    FollowerDao followerDao;

    @Override
    public Boolean addFollower(Follower follower) {
        return followerDao.insert(follower)>0;
    }

    @Override
    public Boolean deleteFollower(Follower follower) {
        HashMap<String,Object> map=new HashMap<>();
        map.put("followerId",follower.getFollowerId());
        map.put("fansId",follower.getFansId());
        return followerDao.deleteByMap(map)>0;
    }

    @Override
    public List<Follower> getFollowers(Long fansId) {
        HashMap<String,Object> map=new HashMap<>();
        map.put("fansId",fansId);
        return followerDao.selectByMap(map);
    }

    @Override
    public List<Follower> getFans(Long followerId) {
        HashMap<String,Object> map=new HashMap<>();
        map.put("followerId",followerId);
        return followerDao.selectByMap(map);
    }
}
